package ldh.fx.adminfx.commpont;

import javafx.scene.control.TextField;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Paint;
import javafx.scene.text.Text;

public class LText extends StackPane {

    private Text text = new Text();
    private TextField textField = new TextField();

    public LText() {
//        textField.setVisible(false);
        text.setFill(Paint.valueOf("transparent"));
        this.getChildren().addAll(text, textField);

        initEvent();
    }

    public LText(String str) {
        super();
        text.setText(str);
        textField.setText(str);
    }

    private void initEvent() {
        this.setOnMouseClicked(this::click);
        textField.setOnMouseClicked(this::click);

    }

    private void click(MouseEvent mouseEvent) {
//        textField.setVisible(true);
//        text.setVisible(false);
        text.textProperty().bind(textField.textProperty());
    }

}
